package com.fwpsl.spring;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@SpringCloudApplication
@RestController
public class hystrixApplication {

    @Value("${spring.application.name:}")
    private String appName;

    @Value("${server.port}")
    private String appPort;

    @RequestMapping("/welcome")
    public String hello() {
        return String.format("Welcome to Hytrix Service! AppName: %s, AppPort: %s", appName, appPort);
    }

    @Bean
    @LoadBalanced
    RestTemplate getRestTemplate(){
        return new RestTemplate();
    }

    public static void main(String[] args) {
        SpringApplication.run(hystrixApplication.class, args);
    }
}
